// pages/login/login.js
Page({
  data: {
    howShow: true,
    mobile: '13733773466', //手机号
    verification: '123456', //验证码
    account: "xbsj001", //账号
    password: "123456", //密码
    send: true
  },
  onLoad({
    redirectURL
  }) {
    // 记下登录成功要返回的页面
    this.redirectURL = redirectURL
    console.log('从上一个页面传入的值是:', redirectURL)
  },
  tChange() {
    this.setData({
      howShow: false
    })
  },
  tChanges() {
    this.setData({
      howShow: true
    })
  },
  send() {
    this.setData({
      send: false
    })
  },
  hEnd() {
    this.setData({
      send: true
    })
  },
  async login() {
    const account = this.data.account || this.data.mobile
    const password = this.data.password || this.data.verification
    // console.log(account,password);
    const res = await wx.http.post('/driver/login/account', {
      account,
      password
    })
    console.log(res);
    const app = getApp()
    app.setToken('token', res.data.data)
    wx.$toast('登陆成功!')
    // 跳转
    console.log('从上一个页面传入的值是:', this.redirectURL)
      const url = this.redirectURL|| '/pages/index/index'
      wx.switchTab({
        url
      })
      // wx.navigateTo({
      //   url
      // })
  }
})